package com.example.demo.async;

import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.AsyncResult;
import org.springframework.stereotype.Component;

import java.util.concurrent.Future;

@Component
public class AsyncTask {

     @Async
    public  Future<String> task_01() throws InterruptedException {
        System.out.println("----------------task_01");
         Thread.sleep(10000);
         System.out.println("--------------01结束");
         return  new AsyncResult<String>("task_01执行完毕");

    }

    @Async
    public Future<String> task_02()throws InterruptedException{
        System.out.println("----------------task_02");
        Thread.sleep(20000);
        System.out.println("--------------02结束");
        return  new AsyncResult<String>("task_02执行完毕");
    }
    @Async
    public Future<String> task_03()throws InterruptedException{
        System.out.println("----------------task_03");
        Thread.sleep(30000);
        System.out.println("--------------03结束");
         return  new AsyncResult<String>("task_03执行完毕");
    }
}
